#!/usr/bin/python
# coding=utf-8
from flask_restplus import Api, Resource, fields
from flask import Flask, request
from flask_restplus import Api, Resource, fields
from flask_restplus._http import HTTPStatus

from .Student import Student
from .TodoList import TodoList
from .TaskAPI import TaskAPI
from .TaskListAPI import TaskListAPI


def create_module(p_app=None, p_api=None):
    #
    ns = p_api.namespace('api_student', description='学生信息模块的API列表', path='/student')

    model_todo = ns.model(ns.name, {
        'id': fields.Integer(readonly=True, description='The task unique identifier'),
        'task': fields.String(required=True, description='The task details')
    })
    model_student = ns.model(ns.name, {
        'name': fields.String(required=True, readonly=True, description='学生姓名'),
        'age': fields.Integer(required=True, readonly=True, description='学生年龄(周岁)'),
        'sex': fields.Integer(required=True, readonly=True, description='学生性别(1/0)')
    })

    ns.add_resource(TaskListAPI, '/task_list.sdo', endpoint='task_list', resource_class_kwargs={'my_bar': 'abc'})
    ns.add_resource(TaskAPI, '/task.sdo', endpoint='task', resource_class_kwargs={'my_bar': 'abc'})

    #path_info = swagger_dict["paths"].get(url)
    #ns.add_resource(doc(ns, views_obj, path_info, url), url, endpoint=views_obj.__name__)
    ns.add_resource(Student, '/student.sdo', endpoint='student', resource_class_kwargs={'my_bar': 'abc'})

    ns.add_resource(TodoList, '/todo_list.sdo', endpoint='todo_list', resource_class_kwargs={'my_bar': 'abc'})
